package cn.tedu.net;

import java.io.*;

public class BufferedReaderDemo {
    public static void main(String[] args) throws IOException {
        method();
        method2();
        method3();
    }

    public static void method3() throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader("D:\\iotest\\1.txt"));
        PrintWriter writer = new PrintWriter(new FileWriter("D:\\iotest\\4.txt"));
        String line = "";
        while ((line = reader.readLine()) != null){
            writer.println(line);
        }
        reader.close();
        writer.close();
    }

    public static void method2() throws IOException {
        //创建对象
        PrintWriter writer = new PrintWriter(new FileWriter("D:\\iotest\\1.txt"));
        writer.println("lzxcqowhesmvhqkafj");
        writer.println("lz0esmvhqkafj");
        writer.println("lz0eskafj");
        writer.println("lz0eskafj3zx4c6a3e");
        writer.println("lz0eskafjas457d897");
        writer.close();
    }

    public static void method() throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader("D:\\iotest\\1.txt"));
        String line = "";
        while ((line = reader.readLine()) != null){
            System.out.println("line = " + line);
        }
        reader.close();
    }
}
